﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Shop
{
    public static class ObjectExt
    {
        public static string GetVal_String(this object oval)
        {
            if (oval != null && oval != DBNull.Value)
            {
                return string.Format("{0}", oval).Trim();
            }
            else
            { return ""; }
        }
        public static double GetVal_Double(this object oval)
        {
            string s = oval.GetVal_String();
            double d;
            double.TryParse(s, out d);
            return d;
        }
        public static decimal GetVal_Decimal(this object oval)
        {
            string s = oval.GetVal_String();
            decimal d;
            decimal.TryParse(s, out d);
            return  d;
        }

        public static int GetVal_Int(this object oval)
        {
            string s = oval.GetVal_String();
            int d;
            int.TryParse(s, out d);
            return d;
        }
    }
}